<!DOCTYPE html>
<html>
<head>
    <title>商品展示页面</title>
    <style>
        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .logo {
            width: 30%;
            margin-top: 20px;
        }
        .input-box {
            margin-top: 20px;
            width: 70%;
            height: 20%;
        }

        .search-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }
        .logo {
            margin-bottom: 20px;
        }
        .search-wrapper {
            display: flex;
            align-items: center;
        }
        .search-input {
            padding: 10px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 4px;
            outline: none;
        }
        .search-button {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #f2f2f2;
            border: 1px solid #ccc;
            border-radius: 4px;
            cursor: pointer;
            margin-left: 10px;
        }
    </style>
    <script src="/static/js/common-header.js"></script>

</head>
<body>
<div class="container">
    <div class="search-container">
        <img src="/static/img/cinda_logo.png" class="logo">

        <div class="search-wrapper">
            <input type="text" class="search-input" placeholder="在Google上搜索" id="searchInput">
            <input type="submit" value="搜索" class="search-button">
        </div>
    </div>


</div>

<script>
    const searchInput = document.getElementById("searchInput");
    const searchButton = document.querySelector(".search-button");
    searchInput.addEventListener("keydown", function(event) {
        if (event.key === "Enter") {
            event.preventDefault();
            console.log("searchInput");
            sendRequest();
        }
    });
    searchButton.addEventListener("click", function() {
        console.log("searchButton");
        sendRequest();
    });
    function sendRequest() {
        const inputValue = searchInput.value;
        const url = "/search" + "?keyword=" + inputValue
            + "&Authorization=" + localStorage.getItem("global_token");
        window.location.href = url ;
        // axios.get(url)
        //     .then(function (response) {
        //         // 处理响应结果
        //         console.log(response.data);
        //     })
        //     .catch(function (error) {
        //         // 处理错误
        //         console.log(error);
        //     });
    }

</script>
</body>
</html>